package programmercarl.数组.C5;

class Solution {
    public static int minSubArrayLen(int target, int[] nums) {
        int i=0,j=-1;
        int sum=0;
        int minLen=Integer.MAX_VALUE;
        while(i<nums.length&&j<nums.length){
            sum+=nums[i];
            while(j<nums.length&&sum>=target){
                minLen=Math.min(minLen,i-j);
                sum-=nums[++j];
            }
                i++;
        }
        return minLen==Integer.MAX_VALUE?0:minLen;
    }

    public static void main(String[] args) {
        minSubArrayLen(7,new int[]{2,3,1,2,4,3});
    }
}